<?php

/**
 * 应用设置
 * 
 * @author ShuangYa
 * @package EUser
 * @category Config
 * @link http://www.sylingd.com/
 * @copyright Copyright (c) 2015-2016 ShuangYa
 * @license http://lab.sylingd.com/go.php?name=euser&type=license
 */

return [
	'name' => 'EUser',
	'appNamespace' => 'euser',
	//调试模式
	'debug' => FALSE,
	//App根目录
	'dir' => __DIR__,
	//编码
	'charset' => 'utf-8',
	//默认语言
	'language' => 'zh-CN',
	//加密Key
	'cookieKey' => '@cookieKey',
	'securityKey' => '@securityKey',
	//是否默认开启CSRF验证
	'csrf' => TRUE,
	//是否启用URL重写
	'rewrite' => TRUE,
	//URL后缀，仅rewrite启用时有效
	'rewriteExt' => 'html',
	//自定义重写规则
	//此处@root作用与YHtml::css中@root作用相同
	'rewriteRule' => [
		'oauthclient/redirect' => '@root/oauthclient/redirect/{{client}}.html',
		'oauthclient/callback' => '@root/oauthclient/callback/{{client}}.html'
	],
	//Controller列表
	'controller' => [
		'oauth',
		'user',
		'oauthclient',
		'app'
	],
	//默认的Router
	'defaultRouter' => 'page/home',
	//会被Autoload加载的class列表
	'class' => [
	],
	//console支持
	//格式：['console函数/方法所在文件', '初始化函数（支持格式同call_user_func）']
	'console' => [
		'default' => ['default.php', 'euser\worker\Worker::Init'],
		'install' => ['install.php', 'Install::Start'],
		'autoinstall' => ['install.php', 'Install::AutoStart'],
		'gendata' => ['install.php', 'Install::GenData']
	],
	//Cookie相关
	'cookie' => [
		'prefix' => '',
		'expire' => 7200,
		'path' => '@app/',
		'domain' => $_SERVER['HTTP_HOST']
	],
	//MongoDB支持
	'mongo' => [
		'host' => '@mongodbHost',
		'port' => '@mongodbPort',
		'name' => '@mongodbName',
		'prefix' => '@mongodbPrefix' //@mongodbUser
	],
	//Swoole基本选项
	'swoole' => [
		'ip' => '0.0.0.0', //监听IP，仅监听本地为127.0.0.1，监听所有地址为0.0.0.0
		'port' => '9500', //监听端口
		'cmd' => [ //控制台配置
			'http' => FALSE,
			'tcp' => [
				'ip' => '127.0.0.1',
				'port' => '9501'
			]
		],
		'pidPath' => '/var/run',
		'http' => [
			'advanced' => [ //关于Swoole的高级选项，一般没有特别说明的，不需要改动
				'daemonize' => TRUE,
				'dispatch_mode' => 3,
				'package_max_length' => 2097152, //1024 * 1024 * 2
				'buffer_output_size' => 3145728, //1024 * 1024 * 3
				'pipe_buffer_size' => 33554432, //1024 * 1024 * 32
				'open_tcp_nodelay' => 1,
				'heartbeat_check_interval' => 5,
				'heartbeat_idle_time' => 11,
				'open_cpu_affinity' => 1,
				'reactor_num' => 2, //建议设置为CPU核数 x 2
				'worker_num' => 2, //守护进程数，详情见http://wiki.swoole.com/wiki/page/275.html
				'task_worker_num' => 2, //Task进程数，详情见http://wiki.swoole.com/wiki/page/276.html
				'max_request' => 0, //必须设置为0
				'task_max_request' => 4000,
				'backlog' => 3000,
				'log_file' => '/tmp/sw_server.log',//swoole系统日志，任何代码内echo都会在这里输出
				'task_tmpdir' => '/tmp/swtasktmp/',//task 投递内容过长时，会临时保存在这里，请将tmp设置使用内存
				'pid_path' => '/var/run/'
			],
			'ssl' => [
				'enable' => FALSE, //HTTPS开关
				'key' => 'ssl.key',
				'cert' => 'ssl.crt'
			],
			'http2' => FALSE //HTTP2协议支持，如果开启HTTP2，则HTTPS也必须开启
		],
		'api' => [
			'port' => 9502,
			'advanced' => [
				'open_length_check' => 1,
				'package_length_type' => 'N',
				'package_length_offset' => 0,
				'package_body_offset' => 4,
				'package_max_length' => 2097152, // 1024 * 1024 * 2,
				'buffer_output_size' => 3145728, //1024 * 1024 * 3,
				'pipe_buffer_size' => 33554432, // 1024 * 1024 * 32,
				'open_tcp_nodelay' => 1,
				'backlog' => 3000,
			]
		]
	]
];